package main

import "fmt"

func readLineInt(num int) []int {
	in := make([]int, 0, num)
	var d int
	for i := 0; i < num; i++ {
		fmt.Scan(&d)
		in = append(in, d)
	}
	return in
}

func main() {
	oneline := readLineInt(2)
	twoline := readLineInt(oneline[0])
	count := 0
	higherthan := 0
	for i := 0; i < oneline[0]; i++ {
		if i+1 == oneline[1] {
			higherthan = twoline[i]
		}
		if twoline[i] >= higherthan && twoline[i] > 0 {
			count++
		} else {
			break
		}
	}
	fmt.Println(count)
}
